package com.soft.bams.entity;

import com.soft.bams.exception.BalanceNotEnoughException;

import java.io.Serializable;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/18
 */
public abstract class Account implements Serializable {

    private static final long serialVersionUID = -5768947619973108347L;
    private Long id;//账户号码
    private String password;
    private String name;
    private String personid;//身份证号码
    private String email;
    private double balance;
    public Account() {
    }
    public Account(Long id, String password, String name,
                   String personid, String email, double balance) {
        this.id = id;
        this.password = password;
        this.name = name;
        this.personid = personid;
        this.email = email;
        this.balance = balance;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPersonid() {
        return personid;
    }

    public void setPersonid(String personid) {
        this.personid = personid;
    }

    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }

    public double getBalance() {
        return balance;
    }
    public void setBalance(double balance) {
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "Account{" + "id=" + id + ", password=" + password + ", name='" + name + ", " +
                "personld=" + personid + ", email=" + email + ", balance=" + balance + "}";
    }
    //取款
    public final void deposit(double money) {
        if (money > 0) {
            balance += money;
        }
    }
    public abstract Account withdraw(double money) throws BalanceNotEnoughException;
}
